var year =prompt("今夕是何年？");
var month =prompt("今夕是何月？");
var dday =prompt("今夕是何日？");
year =Number(year);
month =Number(month);
dday =Number(dday); 	
function runNian(year){
	if(year%400===0||(year%4===0&&year%100!==0)){
		return true;
	}else{
		return false;
	}
}
var days =0;
for(var i=1980;i<year;i++){
	if(runNian(i)){
		days +=366;
	}else{
		days +=365;
	}
}
for(var k=1;k<month;k++){
	switch(k){
	case 1:
		days += 31;
		break;
	case 2:
		if(runNian(year)){
			prevDay +=29;
		}else{
			day +=28;
		}
		break;
	case 3:
		days += 31;
		break;
	case 4:
		days +=30;
		break;
	case 5:
		days +=31;
		break;
	case 6:
		days +=30;
		break;
	case 7:
		days +=31;
		break;
	case 8:
		days +=31;
		break;
	case 9:
		days +=30;
		break;
	case 10:
		days +=31;
		break;
	case 11:
		days +=30;
		break;
	case 12:
		days +=31;
		break;
	}
}
	days +=2;
	var start =days%7;
	var day =document.querySelector("#day");
	var prevDay=0;
	switch (month-1){
	case 0:
		prevDay +=31;
		break;
	case 1:
		prevDay +=31;
		break;
	case 2:
		if(runNian(year)){
			prevDay +=29;
		}else{
			prevDay +=28;
		}
		break;
	case 3:
		prevDay +=31;
		break;
	case 4:
		prevDay +=30;
		break;
	case 5:
		prevDay +=31;
		break;
	case 6:
		prevDay +=30;
		break;
	case 7:
		prevDay +=31;
		break;
	case 8:
		prevDay +=31;
		break;
	case 9:
		prevDay +=30;
		break;
	case 10:
		prevDay +=31;
		break;
	case 11:
		prevDay +=30;
		break;
	case 12:
		prevDay +=31;
		break;
	}

var thisday=0;
switch(month){
	case 1:
		thisday +=31;
		break;
	case 2:
	if(runNian(year)){
		thisday +=29;
	}else{
		thisday +=28;
	}
	break;
	case 3:
		thisday +=31;
		break;
	case 4:
		thisday +=30;
		break;
	case 5:
		thisday +=31;
		break;
	case 6:
		thisday +=30;
		break;
	case 7:
		thisday +=31;
		break;
	case 8:
		thisday +=31;
		break;
	case 9:
		thisday +=30;
		break;
	case 10:
		thisday +=31;
		break;
	case 11:
		thisday +=30;
		break;
	case 12:
		thisday +=31;
		break;
}
   for(var j=prevDay-start+1; j<=prevDay;j++){
   	day.innerHTML +='<span class="h">'+j+'</span>';
   }
	var d =new Date().getDate();
	for(var s=1;s<=thisday;s++){
	if(s ==dday){
		day.innerHTML +='<span class="today">'+s+'</span>';
	}else{
		day.innerHTML +='<span>'+s+'</span>';
	}
}
var num=42;
var endDay =num -start -thisday;
for(var e =1;e<=endDay;e++){
		day.innerHTML +='<span class="h">'+e+'</span>';
}
document.querySelector("#nian").innerHTML =year;
document.querySelector("#yue").innerHTML =month;
document.querySelector("#ri").innerHTML =dday;